<template>
  <div :class="{ 'has-logo': showLogo }">
    <logo v-if="showLogo" :collapse="isCollapse" />
    <el-scrollbar wrap-class="scrollbar-wrapper">
      <el-menu
        :default-active="activeMenu"
        :collapse="isCollapse"
        :unique-opened="true"
        :collapse-transition="false"
        background-color="#545c64"
        text-color="#fff"
        active-text-color="#ffd04b"
        mode="vertical"
      >
        <sidebar-item
          v-for="(route, index) in permission_routes"
          :key="route.path + index"
          :item="route"
          :base-path="route.path"
        />
      </el-menu>
    </el-scrollbar>
  </div>
</template>

<script>
import Logo from "./Logo";
import SidebarItem from "./SidebarItem";

export default {
  components: { SidebarItem, Logo },
  data() {
    return {
      permission_routes: [
        {
          name: "Xqgl",
          path: "/xqgl",
          hidden: false,
          redirect: "noRedirect",
          component: "Layout",
          alwaysShow: true,
          meta: { title: "小区管理", icon: "upload", noCache: false },
          children: [
            {
              name: "Community",
              path: "community",
              hidden: false,
              component: "baseData/community/index",
              meta: { title: "小区信息", icon: "validCode", noCache: false },
            },
            {
              name: "Building",
              path: "building",
              hidden: false,
              component: "baseData/building/index",
              meta: { title: "楼栋信息", icon: "zip", noCache: false },
            },
            {
              name: "House",
              path: "house",
              hidden: false,
              component: "baseData/house/index",
              meta: { title: "房屋信息", icon: "table", noCache: false },
            },
            {
              name: "Video/video",
              path: "video/video",
              hidden: false,
              component: "video/video/index",
              meta: { title: "视频管理", icon: "radio", noCache: false },
            },
          ],
        },
        {
          name: "Rkgl",
          path: "/rkgl",
          hidden: false,
          redirect: "noRedirect",
          component: "Layout",
          alwaysShow: true,
          meta: { title: "人口管理", icon: "user", noCache: false },
          children: [
            {
              name: "Lrlc/lr",
              path: "lrlc/lr",
              hidden: false,
              component: "baseData/lrlc/lr/index",
              meta: { title: "流入人口", icon: "peoples", noCache: false },
            },
            {
              name: "Population",
              path: "population",
              hidden: false,
              component: "baseData/population/index",
              meta: { title: "人口信息", icon: "wechat", noCache: false },
            },
            {
              name: "Lrlc/lc",
              path: "lrlc/lc",
              hidden: false,
              component: "baseData/lrlc/lc/index",
              meta: { title: "流出人口", icon: "peoples", noCache: false },
            },
            {
              name: "RyPassRecord",
              path: "ryPassRecord",
              hidden: false,
              component: "baseData/ryPassRecord/index",
              meta: {
                title: "人员出入记录",
                icon: "component",
                noCache: false,
              },
            },
            {
              name: "TemperatureRecord",
              path: "temperatureRecord",
              hidden: false,
              component: "baseData/temperatureRecord/index",
              meta: { title: "测温记录", icon: "slider", noCache: false },
            },
            {
              name: "SecondMenus/gsry",
              path: "secondMenus/gsry",
              hidden: false,
              redirect: "noRedirect",
              component: "secondMenus/gsry/index",
              alwaysShow: true,
              meta: { title: "关受人员", icon: "theme", noCache: false },
              children: [
                {
                  name: "Fwjzrkfx/gsry",
                  path: "fwjzrkfx/gsry",
                  hidden: false,
                  component: "counts/fwjzrkfx/gsry/index",
                  meta: {
                    title: "关受人员属性统计",
                    icon: "clipboard",
                    noCache: false,
                  },
                  children: [
                    {
                      name: "Fwjzrkfx1/gsry",
                      path: "fwjzrkfx1/gsry",
                      hidden: false,
                      component: "counts/fwjzrkfx/gsry/index1",
                      meta: {
                        title: "1关受人员属性统计1",
                        icon: "clipboard",
                        noCache: false,
                      },
                    },
                    {
                      name: "aFwjzrkfx1/gsry",
                      path: "afwjzrkfx1/gsry",
                      hidden: false,
                      component: "acounts/fwjzrkfx/gsry/index1",
                      meta: {
                        title: "a1关受人员属性统计1",
                        icon: "clipboard",
                        noCache: false,
                      },
                    },
                  ],
                },
                {
                  name: "Populationdb",
                  path: "populationdb",
                  hidden: false,
                  component: "baseData/populationdb/index",
                  meta: { title: "低保户", icon: "peoples", noCache: false },
                },
                {
                  name: "Populatoncj",
                  path: "populatoncj",
                  hidden: false,
                  component: "baseData/populationcj/index",
                  meta: { title: "残疾人", icon: "dashboard", noCache: false },
                },
                {
                  name: "Populationgl",
                  path: "populationgl",
                  hidden: false,
                  component: "baseData/populationgl/index",
                  meta: { title: "高龄人员", icon: "github", noCache: false },
                },
                {
                  name: "Populationshkn",
                  path: "populationshkn",
                  hidden: false,
                  component: "baseData/populationshkn/index",
                  meta: {
                    title: "生活困难人员",
                    icon: "color",
                    noCache: false,
                  },
                },
                {
                  name: "Populationsyry",
                  path: "populationsyry",
                  hidden: false,
                  component: "baseData/populationsyry/index",
                  meta: { title: "失业人员", icon: "link", noCache: false },
                },
                {
                  name: "Populationylfn",
                  path: "populationylfn",
                  hidden: false,
                  component: "baseData/populationylfn/index",
                  meta: { title: "育龄妇女", icon: "drag", noCache: false },
                },
              ],
            },
            {
              name: "SecondMenus/zdrk",
              path: "secondMenus/zdrk",
              hidden: false,
              redirect: "noRedirect",
              component: "secondMenus/zdrk/index",
              alwaysShow: true,
              meta: { title: "重点人口", icon: "star", noCache: false },
              children: [
                {
                  name: "Warning/zdryWarning",
                  path: "warning/zdryWarning",
                  hidden: false,
                  component: "baseData/warning/zdryWarning/index",
                  meta: {
                    title: "重点人员预警监控",
                    icon: "user",
                    noCache: false,
                  },
                },
                {
                  name: "Teenager",
                  path: "teenager",
                  hidden: false,
                  component: "baseData/teenager/index",
                  meta: {
                    title: "重点青少年信息",
                    icon: "eye-open",
                    noCache: false,
                  },
                },
                {
                  name: "Emancipist",
                  path: "emancipist",
                  hidden: false,
                  component: "baseData/emancipist/index",
                  meta: {
                    title: "刑满释放人员信息",
                    icon: "chart",
                    noCache: false,
                  },
                },
                {
                  name: "Drugs",
                  path: "drugs",
                  hidden: false,
                  component: "baseData/drugs/index",
                  meta: { title: "吸毒人员", icon: "checkbox", noCache: false },
                },
                {
                  name: "Psychosis",
                  path: "psychosis",
                  hidden: false,
                  component: "baseData/psychosis/index",
                  meta: {
                    title: "精神病人员信息",
                    icon: "button",
                    noCache: false,
                  },
                },
                {
                  name: "Correct",
                  path: "correct",
                  hidden: false,
                  component: "baseData/correct/index",
                  meta: {
                    title: "社区矫正人员信息",
                    icon: "code",
                    noCache: false,
                  },
                },
              ],
            },
          ],
        },
        {
          name: "Http://ruoyi.vip",
          path: "http://ruoyi.vip",
          hidden: true,
          component: "Layout",
          meta: { title: "若依官网", icon: "guide", noCache: false },
        },
        {
          name: "Fkgl",
          path: "/fkgl",
          hidden: false,
          redirect: "noRedirect",
          component: "Layout",
          alwaysShow: true,
          meta: { title: "访客管理", icon: "user", noCache: false },
          children: [
            {
              name: "Visitor",
              path: "visitor",
              hidden: false,
              component: "baseData/visitor/index",
              meta: { title: "访客出入记录", icon: "select", noCache: false },
            },
          ],
        },
        {
          name: "Clgl",
          path: "/clgl",
          hidden: false,
          redirect: "noRedirect",
          component: "Layout",
          alwaysShow: true,
          meta: { title: "车辆管理", icon: "monitor", noCache: false },
          children: [
            {
              name: "CarArchives",
              path: "carArchives",
              hidden: false,
              component: "baseData/carArchives/index",
              meta: { title: "车辆档案", icon: "tab", noCache: false },
            },
            {
              name: "CarPassRecord",
              path: "carPassRecord",
              hidden: false,
              component: "baseData/carPassRecord/index",
              meta: { title: "车辆出入记录", icon: "tree", noCache: false },
            },
          ],
        },
        {
          name: "Yjgl",
          path: "/yjgl",
          hidden: false,
          redirect: "noRedirect",
          component: "Layout",
          alwaysShow: true,
          meta: { title: "预警管理", icon: "bug", noCache: false },
          children: [
            {
              name: "Warning",
              path: "warning",
              hidden: false,
              component: "baseData/warning/index",
              meta: { title: "预警信息", icon: "switch", noCache: false },
            },
            {
              name: "WarningSet",
              path: "warningSet",
              hidden: false,
              component: "baseData/warningSet/index",
              meta: { title: "预警配置", icon: "button", noCache: true },
            },
          ],
        },
        {
          name: "System",
          path: "/system",
          hidden: false,
          redirect: "noRedirect",
          component: "Layout",
          alwaysShow: true,
          meta: { title: "系统管理", icon: "system", noCache: false },
          children: [
            {
              name: "User",
              path: "user",
              hidden: false,
              component: "system/user/index",
              meta: { title: "用户管理", icon: "user", noCache: false },
            },
            {
              name: "Role",
              path: "role",
              hidden: false,
              component: "system/role/index",
              meta: { title: "角色管理", icon: "peoples", noCache: false },
            },
            {
              name: "Menu",
              path: "menu",
              hidden: false,
              component: "system/menu/index",
              meta: { title: "菜单管理", icon: "tree-table", noCache: false },
            },
            {
              name: "Dept",
              path: "dept",
              hidden: false,
              component: "system/dept/index",
              meta: { title: "部门管理", icon: "tree", noCache: false },
            },
            {
              name: "Post",
              path: "post",
              hidden: false,
              component: "system/post/index",
              meta: { title: "岗位管理", icon: "post", noCache: false },
            },
            {
              name: "Dict",
              path: "dict",
              hidden: false,
              component: "system/dict/index",
              meta: { title: "字典管理", icon: "dict", noCache: false },
            },
            {
              name: "Config",
              path: "config",
              hidden: false,
              component: "system/config/index",
              meta: { title: "参数设置", icon: "edit", noCache: false },
            },
            {
              name: "Notice",
              path: "notice",
              hidden: false,
              component: "system/notice/index",
              meta: { title: "通知公告", icon: "message", noCache: false },
            },
            {
              name: "SecondMenus/czrz",
              path: "secondMenus/czrz",
              hidden: false,
              redirect: "noRedirect",
              component: "secondMenus/czrz/index",
              alwaysShow: true,
              meta: { title: "日志管理", icon: "log", noCache: false },
              children: [
                {
                  name: "Operlog",
                  path: "operlog",
                  hidden: false,
                  component: "monitor/operlog/index",
                  meta: { title: "操作日志", icon: "form", noCache: false },
                },
                {
                  name: "Logininfor",
                  path: "logininfor",
                  hidden: false,
                  component: "monitor/logininfor/index",
                  meta: {
                    title: "登录日志",
                    icon: "logininfor",
                    noCache: false,
                  },
                },
              ],
            },
          ],
        },
        {
          name: "Tool",
          path: "/tool",
          hidden: false,
          redirect: "noRedirect",
          component: "Layout",
          alwaysShow: true,
          meta: { title: "系统工具", icon: "tool", noCache: false },
          children: [
            {
              name: "Build",
              path: "build",
              hidden: false,
              component: "tool/build/index",
              meta: { title: "表单构建", icon: "build", noCache: false },
            },
            {
              name: "Gen",
              path: "gen",
              hidden: false,
              component: "tool/gen/index",
              meta: { title: "代码生成", icon: "code", noCache: false },
            },
            {
              name: "Swagger",
              path: "swagger",
              hidden: false,
              component: "tool/swagger/index",
              meta: { title: "系统接口", icon: "swagger", noCache: false },
            },
          ],
        },
        {
          name: "Monitor",
          path: "/monitor",
          hidden: false,
          redirect: "noRedirect",
          component: "Layout",
          alwaysShow: true,
          meta: { title: "系统监控", icon: "monitor", noCache: false },
          children: [
            {
              name: "Online",
              path: "online",
              hidden: false,
              component: "monitor/online/index",
              meta: { title: "在线用户", icon: "online", noCache: false },
            },
            {
              name: "Job",
              path: "job",
              hidden: false,
              component: "monitor/job/index",
              meta: { title: "定时任务", icon: "job", noCache: false },
            },
            {
              name: "Druid",
              path: "druid",
              hidden: false,
              component: "monitor/druid/index",
              meta: { title: "数据监控", icon: "druid", noCache: false },
            },
            {
              name: "Server",
              path: "server",
              hidden: false,
              component: "monitor/server/index",
              meta: { title: "服务监控", icon: "server", noCache: false },
            },
            {
              name: "Cache",
              path: "cache",
              hidden: false,
              component: "monitor/cache/index",
              meta: { title: "缓存监控", icon: "redis", noCache: false },
            },
          ],
        },
      ],
    };
  },
  computed: {
    activeMenu() {
      const route = this.$route;
      const { meta, path } = route;
      // if set path, the sidebar will highlight the path you set
      if (meta.activeMenu) {
        return meta.activeMenu;
      }
      return path;
    },
    showLogo() {
      return "/static/meimei.jpg";
    },
    isCollapse() {
      return false;
    },
  },
};
</script>
